package com.by.servlet;

import com.by.http.HttpRequest;
import com.by.http.HttpResponse;

// 抽象类 HttpServlet
public abstract class HttpServlet implements Servlet {
    @Override
    public void init() throws Exception {}

    @Override
    public void service(HttpRequest request, HttpResponse response) throws Exception {
        if ("GET".equalsIgnoreCase(request.getMethod())) {
            doGet(request, response);
        } else if ("POST".equalsIgnoreCase(request.getMethod())) {
            doPost(request, response);
        }
    }

    protected void doGet(HttpRequest request, HttpResponse response) throws Exception {}

    protected void doPost(HttpRequest request, HttpResponse response) throws Exception {}

    @Override
    public void destroy() {}
}
